/*
 * @Author: ecitlm
 * @Date:   2017-12-02 13:13:49
 * @Last Modified by: ecitlm
 * @Last Modified time: 2018-06-30 17:23:12
 */
let express = require('express')
let app = express()
let ejs = require('ejs')
const myajax = require('../../utils/fetch')
// 这里也可以配置识别HTML
app.engine('ejs', ejs.__express) // 配置识别ejs模板
app.set('view engine', 'ejs') // 设置模板扩展名后缀自动添加
app.set('views', './views/web') // 设置模板路径
app.get('/', function (req, res) {
  myajax
    .get('/api/new_songs', {})
    .then(function (response) {
        let data = response.data;
        res.render('newsongs',{
            data:data
        });
    })
    .catch(function (err) {
      console.log(err)
    })
})

app.get('/info/:hash', function (req, res) {
    let hash = req.params.hash
    myajax
        .get('/api/singer_info/'+hash, {})
        .then(function (response) {
            let data = response.data;
            console.log(data);
            res.send('12233')
        })
        .catch(function (err) {
            console.log(err)
        })
})

module.exports = app
